package com.ebt.m.homepage;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ebt.m.R;
import com.ebt.m.data.rxModel.apibean.DynamicsCountData;
import com.ebt.m.utils.DateUtils;

/**
 * Created by andy.wang on 2016/12/8.
 */

public class ActiveView extends DynamicBaseView {
    private LinearLayout mContent;
    private TextView mPhoneCount;
    private TextView mProposalCount;
    private TextView mActiveTitle;

    public ActiveView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ActiveView(Context context) {
        this(context, null);
    }

    public ActiveView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        inflate(context, R.layout.layout_4homepage_active, this);
        initView();
    }

    private void initView() {
        mContent = (LinearLayout) findViewById(R.id.content);
        mPhoneCount = (TextView) findViewById(R.id.phone_count);
        mProposalCount = (TextView) findViewById(R.id.proposal_count);
        mActiveTitle = (TextView) findViewById(R.id.active_title);
    }


    @Override
    public void update(Object... args) {
        int phoneCount = 0;
        int proposalCount = 0;
        DynamicsCountData countData = (DynamicsCountData) args[0];
        if (countData != null) {
            phoneCount = countData.getPhoneTalkCount();
            proposalCount = countData.getSendProposalCount();
        }
        mActiveTitle.setText(DateUtils.getCurrentMonth() + getResources().getString(R.string.month_active_title));
        mPhoneCount.setText(phoneCount + "个");
        mProposalCount.setText(proposalCount + "个");

    }
}
